package com.southwind.controller;


import com.southwind.entity.TbTaskAttack;
import com.southwind.entity.TbTaskScan;
import com.southwind.form.SearchForm;
import com.southwind.service.TbTaskAttackService;
import com.southwind.service.TbTaskScanService;
import com.southwind.util.ResultVOUtil;
import com.southwind.vo.PageVO;
import com.southwind.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fjh
 * @since 2024-01-11
 */
@RestController
@RequestMapping("/tbTaskScan")
public class TbTaskScanController {
    @Autowired
    private TbTaskScanService tbTaskScanService;

    @PostMapping("/save")
    public ResultVO save(@RequestBody TbTaskScan tbTaskScan) {
        boolean save = this.tbTaskScanService.save(tbTaskScan);
        if (!save) return ResultVOUtil.fail();
        return ResultVOUtil.success(null);
    }
    @GetMapping("/list/{page}/{size}")
    public ResultVO list(@PathVariable("page") Integer page,@PathVariable("size") Integer size){
        PageVO pageVO = this.tbTaskScanService.list(page, size);
        return ResultVOUtil.success(pageVO);
    }
    @GetMapping("/search")
    public ResultVO search(SearchForm searchForm){
        PageVO pageVO = this.tbTaskScanService.search(searchForm);
        return ResultVOUtil.success(pageVO);
    }
    @GetMapping("/findById/{id}")
    public ResultVO findById(@PathVariable("id") Integer id){
        TbTaskScan tbTaskScan = this.tbTaskScanService.getById(id);
        return ResultVOUtil.success(tbTaskScan);
    }

    @PutMapping("/update")
    public ResultVO update(@RequestBody TbTaskScan tbTaskScan){
        boolean update = this.tbTaskScanService.updateById(tbTaskScan);
        if(!update) return ResultVOUtil.fail();
        return ResultVOUtil.success(null);
    }

    @DeleteMapping("/deleteById/{id}")
    public ResultVO deleteById(@PathVariable("id") Integer id){
        boolean remove = this.tbTaskScanService.removeById(id);
        if(!remove) return ResultVOUtil.fail();
        return ResultVOUtil.success(null);
    }
    @GetMapping("/list")
    public ResultVO list(){
        List<TbTaskScan> tbTaskScanList = this.tbTaskScanService.list();
        return ResultVOUtil.success(tbTaskScanList);
    }
}

